package taller2.controller.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import taller2.view.components.CharacterBox;
import taller2.view.components.HighlightBar;
import taller2.view.menus.CodeBrowser;

public class HighlightMenuListener implements ActionListener{
	private HighlightBar bar;
	private CodeBrowser browser;
	CharacterBox panelTxt;
	// constructor
	public HighlightMenuListener(HighlightBar bar,CodeBrowser browser, CharacterBox panelTxt){
		this.bar = bar;
		this.browser = browser;
		this.panelTxt = panelTxt;
		
	}
	
	// detects and executes the events
	public void actionPerformed(ActionEvent event){
		Object source = event.getSource(); 	

		if(bar.isHighlightNextButton(source)){
			browser.stepForward();
		}else if(bar.isHighlightPrevButton(source)){
			browser.stepBackwards();
		}else if(bar.isResetButton(source)){
			browser.reset();
		}	
		bar.unselectButtons();		
	}
}
